home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / AppleEvents / Events / AEEvent.cp < prev    next >
Text File  |  2000-06-23  |  2KB  |  87 lines

  1. // AEEvent.cp
  2.  
  3. #ifndef AEEvent_h
  4. #include "AEEvent.h"
  5. #endif
  6. #ifndef OSError_h
  7. #include "OSError.h"
  8. #endif
  9. #ifndef AEAddress_h
  10. #include "AEAddress.h"
  11. #endif
  12.  
  13. #include <Errors.h>
  14.  
  15. AEEvent::AEEvent( AEVerb verb,
  16.                         const AEAddress& target )
  17.   {
  18.     ThrowOSError( AECreateAppleEvent( verb.Suite().Suite(),
  19.                                                  verb.Event(),
  20.                                                  &target,
  21.                                                  kAutoGenerateReturnID,
  22.                                                  kAnyTransactionID,
  23.                                                  this ) );
  24.   }
  25.  
  26. AEEvent::AEEvent( AESuite suite,
  27.                         AEEventID event,
  28.                         const AEAddress& target )
  29.   {
  30.     ThrowOSError( AECreateAppleEvent( suite.Suite(),
  31.                                                  event,
  32.                                                  &target,
  33.                                                  kAutoGenerateReturnID,
  34.                                                  kAnyTransactionID,
  35.                                                  this ) );
  36.   }
  37.  
  38. uint32 AEEvent::ParameterCount() const
  39.   {
  40.     Assert( !IsNull() );
  41.     int32 length;
  42.     ThrowOSError( AECountItems( this, &length ) );
  43.     Assert( length >= 0 );
  44.     return length;
  45.   }
  46.  
  47. bool AEEvent::MissedParameter() const
  48.   {
  49.     return Attribute( AEKey( keyMissedKeywordAttr ) ).Exists();
  50.   }
  51.  
  52. void AEEvent::ThrowMissedParameter() const
  53.   {
  54.     if ( MissedParameter() )
  55.         throw OSError( errAEParamMissed );
  56.   }
  57.  
  58. AEVerb AEEvent::Verb() const
  59.   {
  60.     AEEventClass suite;
  61.     Attribute( keyEventClassAttr ) >> Data( &suite, sizeof(suite) );
  62.     
  63.     AEEventID event;
  64.     Attribute( keyEventIDAttr ) >> Data( &event, sizeof(event) );
  65.     
  66.     return AEVerb( suite, event );
  67.   }
  68.  
  69. pascal Boolean AEEvent::IgnoreEvents( EventRecord *,
  70.                                                   int32 *sleepTime,
  71.                                                   RgnHandle *mouseRegion )
  72.   {
  73.     *sleepTime = 0x40000000;
  74.     *mouseRegion = 0;
  75.     return false;
  76.   }
  77.  
  78. AEIdleUPP AEEvent::IgnoreIncomingEvents()
  79.   {
  80.     #if GENERATINGCFM
  81.         static RoutineDescriptor IgnoreEvents =
  82.             BUILD_ROUTINE_DESCRIPTOR( uppAEIdleProcInfo, &AEEvent::IgnoreEvents );
  83.     #endif
  84.     
  85.     return &IgnoreEvents;
  86.   }
  87.